<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增机具采购奖励标准')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-toolsReward-add" th:with="type=${@dict.getType('tools_reward_gears')}">
            <div th:each="dict : ${type}">
                <fieldset>
                    <legend th:text="${dict.dictLabel}"></legend>
                    <input th:name="'id'+ ${dict.dictValue}" th:each="item,tr:${toolsRewards}" th:if="${tr.current.key=='id'+dict.dictValue}" th:value="${tr.current.value}" type="hidden" required>
                    <input th:name="'gears'+ ${dict.dictValue}" th:value="${dict.dictValue}" type="hidden" required>
                    <div class="col-md-5">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">购机数量：</label>
                            <div class="col-sm-6" th:each="item,tr:${toolsRewards}" th:if="${tr.current.key=='toolsNumber'+dict.dictValue}">
                                <input th:name="'toolsNumber' + ${dict.dictValue}" th:value="${tr.current.value}" class="form-control" type="text" required  >
                            </div>
                            <div class="col-sm-6"  th:if="${flag=='0'}">
                                <input th:name="'toolsNumber' + ${dict.dictValue}" value="" class="form-control" type="text" required  >
                            </div>
                        </div>
                    </div>
                    <div class="col-md-5">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">奖励金额(每台)：</label>
                            <div class="col-sm-6" th:each="item,tr:${toolsRewards}" th:if="${tr.current.key=='rewardMoney'+dict.dictValue}">
                                <input th:name="'rewardMoney' + ${dict.dictValue}" th:value="${tr.current.value}" class="form-control" type="text" required  >
                            </div>
                            <div class="col-sm-6"  th:if="${flag=='0'}">
                                <input th:name="'rewardMoney' + ${dict.dictValue}" value="" class="form-control" type="text" required  >
                            </div>
                        </div>
                    </div>

                </fieldset>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "toolsReward/toolsReward";
        var toolsRewardGears = [[${@dict.getType('tools_reward_gears')}]];
        var rules = {};
        $(toolsRewardGears).each(function (index, dict) {
            var toolsNumber = {};
            toolsNumber.required = true;
            toolsNumber.digits=true;
            toolsNumber.min=1;
            rules['toolsNumber'+dict.dictValue] = toolsNumber;
            var rewardMoney = {};
            rewardMoney.required = true;
            rewardMoney.number=true;
            rewardMoney.min=0;
            rules['rewardMoney'+dict.dictValue] = rewardMoney;
        });
        $("#form-toolsReward-add").validate({
            rules:rules,
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-toolsReward-add').serialize());
            }
        }
    </script>
</body>
</html>